package com.zmj.sy.mom.srv.aps.utils;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.LinkedHashMap;
import java.util.Map;

@Getter
@Setter
@NoArgsConstructor
public class LogApiType {

    private String type;

    private String code;

    private String url;

    private Map<String, String> attr;

    public LogApiType(String type, String code, String url, String... attrEntries) {
        this.type = type;
        this.code = code;
        this.url = url;
        if (attrEntries == null || attrEntries.length == 0) {
            return ;
        }

        if(attrEntries.length % 2 != 0){
            throw SyExceptionUtils.e("KEY_VALUE_PAIR_NOT_MATCH");
        }
        attr = new LinkedHashMap<>();

        for (int i = 0; i < attrEntries.length; i += 2) {
            attr.put(attrEntries[i], attrEntries[i + 1]);
        }

    }

}
